<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="template.xhtml">
	<ui:define name="content">
		<h:form>
			<p:growl id="msg" showDetail="true" escape="false" />

			<h3 style="margin-top: 0">Basic PickList</h3>
			<p:pickList id="pickList" value="#{registerControler.departments}"
				var="department" itemLabel="#{department.name}"
				itemValue="#{department}" showSourceFilter="true"
				showTargetFilter="true" filterMatchMode="contains"
				converter="DepartmentConverter">
				<f:facet name="sourceCaption">#{dictionaryControler.dictionary['Off']}</f:facet>
				<f:facet name="targetCaption">#{dictionaryControler.dictionary['On']}</f:facet>

				<p:column>
					<h:outputText value="#{department.name}" />
				</p:column>
			</p:pickList>

			<p:commandButton id="citySubmit" value="Submit"
				actionListener="#{registerControler.submit}"
				update="displayCities,selOneDepartment"
				oncomplete="PF('cityDialog').show()" style="margin-top:5px" />

			<br/>

			<p:selectOneMenu id="selOneDepartment"
				value="#{registerControler.selectedDepartment}">
				<f:selectItem itemLabel="Select One" itemValue="#{-1}"
					noSelectionOption="true" />
				<f:selectItems value="#{registerControler.onlineDepartments}"
					var="department" itemLabel="#{department.name}"
					itemValue="#{department.seq}" />
				<p:ajax listener="#{registerControler.onSelectDepartment}"
					update="doctorPickList" />
			</p:selectOneMenu>

			<p:pickList id="doctorPickList" value="#{registerControler.doctors}"
				var="doctor" itemLabel="#{doctor.name}" itemValue="#{doctor}"
				showSourceFilter="true" showTargetFilter="true"
				filterMatchMode="contains" converter="DoctorConverter">
				<f:facet name="sourceCaption">#{dictionaryControler.dictionary['Off']}</f:facet>
				<f:facet name="targetCaption">#{dictionaryControler.dictionary['On']}</f:facet>

				<p:column>
					<h:outputText value="#{doctor.name}" />
				</p:column>
			</p:pickList>

			<p:commandButton value="Submit"
				actionListener="#{registerControler.submit2}" update="displayCities"
				oncomplete="PF('cityDialog').show()" style="margin-top:5px" />



			<p:dialog showEffect="fade" hideEffect="fade" widgetVar="cityDialog">
				<h:panelGrid id="displayCities" columns="2">
					<h:outputText value="Source: " style="font-weight:bold" />
					<ui:repeat value="#{registerControler.offlineDepartments}"
						var="item">
						<h:outputText value="#{item.name}" style="margin-right:5px" />
					</ui:repeat>

					<h:outputText value="Target: " style="font-weight:bold" />
					<ui:repeat value="#{registerControler.onlineDepartments}"
						var="item">
						<h:outputText value="#{item.name}" style="margin-right:5px" />
					</ui:repeat>

					<h:outputText value="Source: " style="font-weight:bold" />
					<ui:repeat value="#{registerControler.offlineDoctors}" var="item">
						<h:outputText value="#{item.name}" style="margin-right:5px" />
					</ui:repeat>

					<h:outputText value="Target: " style="font-weight:bold" />
					<ui:repeat value="#{registerControler.onlineDoctors}" var="item">
						<h:outputText value="#{item.name}" style="margin-right:5px" />
					</ui:repeat>
				</h:panelGrid>
			</p:dialog>
		</h:form>
	</ui:define>
</ui:composition>
</html>